package com.blacksheep.mtm.controller;


import com.blacksheep.mtm.common.utils.ResultUtil;
import com.blacksheep.mtm.pojo.common.DataTablesResult;
import com.blacksheep.mtm.pojo.common.Result;
import com.blacksheep.mtm.service.BounsService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/api/bouns")
public class BounsController {

    @Autowired
    private BounsService bounsService;

    @RequestMapping(value = "/hospital/list",method = RequestMethod.GET)
    @ApiOperation(value = "统计")
    public DataTablesResult gethospitalList(int draw, int start, int length, String searchKey, int[] state,
                                            String minDate, String maxDate,
                                            @RequestParam("search[value]") String search,
                                            @RequestParam("order[0][column]") int orderCol,
                                            @RequestParam("order[0][dir]") String orderDir){

        //获取客户端需要排序的列
//        String[] cols = {"checkbox","hospital_id", "hospital_name","hospital_province", "hospital_city", "hospital_dis", "hospital_address", "create_time","state"};
//        String orderColumn = cols[orderCol];
//        //默认排序列
//        if(orderColumn == null) {
//            orderColumn = "create_time";
//        }
//        //获取排序方式 默认为desc(asc)
//        if(orderDir == null) {
//            orderDir = "desc";
//        }
//        if (!StringUtils.isBlank(search)){
//            searchKey =search;
//        }
//        DataTablesResult result= bounsService.getHospitalList(draw,start,length,state,searchKey,minDate,maxDate,orderColumn,orderDir);
//        return result;
        return null;
    }


    //抽奖剩余次数
    @RequestMapping(value = "/count",method = RequestMethod.GET)
    @ResponseBody
    public Result<Integer> bounsCount(String openid){
        int result = bounsService.getBounsListCount(openid);
        return new ResultUtil<Integer>().setData(result);
    }


    //当前积分
    @RequestMapping(value = "/points",method = RequestMethod.GET)
    @ResponseBody
    public Result<Integer> getPoints(String openid){
        int result = bounsService.getBounsPoints(openid);
        return new ResultUtil<Integer>().setData(result);
    }
}
